﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AccountsForm.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.AccountsForm" %>
<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Domain.Components" %>
<%@ Import Namespace="AcademicPlanner.Domain.Models" %>

<% if (!Model.IsSub)
   { %>
		<div class="form yui-skin-sam">
		<% Begin(); %>
<% } %>

<% if (!string.IsNullOrEmpty(Title))
   { %>
		<fieldset><legend><%= Html.Encode(Title) %></legend>
<% } %>

<% if (!Model.IsSub)
   { %>
		<%= WidgetHelper.FormErrorsBlock("", Model.Id + "Errors", "hidden") %>
<% } %>


<% for (var vIndex=0; vIndex<Model.UserNames.Count; vIndex++)
{ %>
	<fieldset>
		<legend>
			<%= Html.RadioButton("accountIndex", vIndex, (vIndex == 0), new { onclick = "gAccountsFormCtrl.disableEnableUserFields(event, this)" } )%>
			<i><%= Html.Label("accountIndex", Html.Encode(Model.UserNames[vIndex])) %></i>
		</legend>
		<div class="rows-wrapper">
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Password", "User", vIndex), 
									Html.Encode(Tr(Labels.Get("Password", "User"))), true)%>
				</div>
				<div class="cell field">
					<%= Html.Password(GetFieldName("Password", "User", vIndex), "", ((vIndex > 0) ? new { disabled = "disabled", size = 20, maxlength = 20 } : new object()))%>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("between {0} and {1} characters, alphanumerics and " +
															"\"_&*$#@!?\" only"), 
					                   					User.PASSWORD_MIN_LENGTH,
					                   					User.PASSWORD_MAX_LENGTH)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("RepeatedPassword", "User", vIndex), 
									Html.Encode(Tr(Labels.Get("RepeatedPassword", "User"))), true)%>
				</div>
				<div class="cell field">
					<%= Html.Password(GetFieldName("RepeatedPassword", "User", vIndex), "", ((vIndex > 0) ? new { disabled = "disabled", size = 20, maxlength = 20 } : new object()))%>
				</div>
				<div class="cell">
					&nbsp;
				</div>
			</div>
		</div>
	</fieldset>
<% } %>
	

<% if (!Model.IsSub)
   { %>
		<div class="rows-wrapper action">
			<div class="row">
				<div class="cell label">
					&nbsp;
				</div>
				<div class="cell">
					<%= Html.SubmitButton("submitForm", Html.Encode(SubmitButtonValue), SubmitButtonExtraAttributes)%>
				</div>
			</div>
		</div>
<% } %>


<% if (!string.IsNullOrEmpty(Title))
   { %>
		</fieldset>
<% } %>


<% if (!Model.IsSub)
   { %>
		<% End(); %>
		</div>
<% } %>